package com.dwxt.cdms.controller;

import com.dwxt.cdms.base.Page;
import com.dwxt.cdms.entity.MedicalRecord;
import com.dwxt.cdms.entity.base.MediaRecordExt;
import com.dwxt.cdms.service.MediaRecordService;
import com.dwxt.common.base.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/cdms/mediaRecord")
@RestController
public class MediaRecordController {

    @Autowired
    private MediaRecordService mediaRecordService;

    @RequestMapping("/selectMediaRecordByCondition")
    public BaseResult selectMediaRecordByCondition(MedicalRecord medicalRecord, String startTime, String endTime,
                                                   Page page){
        return  mediaRecordService.selectMediaRecordByCondition(medicalRecord,startTime,endTime,page);
    }

    //插入体检报告记录和图片记录
    @RequestMapping("/insert")
    public BaseResult insert(@RequestBody MediaRecordExt mediaRecordExt){
        return mediaRecordService.insert(mediaRecordExt);
    }

    @RequestMapping("/selectMediaRecordImg")
    public BaseResult selectMediaRecordImg(Integer medicalRecordId){
        return BaseResult.ok(mediaRecordService.selectMediaRecordImg(medicalRecordId));
    }

    @RequestMapping("/delete")
    public BaseResult delete(Integer id){
        return mediaRecordService.delete(id);
    }

    @RequestMapping("/update")
    public BaseResult update(@RequestBody MediaRecordExt mediaRecordExt){
        return mediaRecordService.update(mediaRecordExt);
    }

    @RequestMapping("/selectMediaById")
    public BaseResult selectMediaById(Integer id){
        return  mediaRecordService.selectMediaById(id);
    }

}
